/*
 * 5.6
 * Write a program to swap odd and even bits in an integer with as few instructions as
 * possible (e.g., bit 0 and bit 1 are swapped, bit 2 and bit 3 are swapped, etc).
 */
#include <stdio.h>

int swapbits(int i)
{
    return ((0x55555555 & i) << 1) | ((0xAAAAAAAA & i) >> 1);
}

int main()
{
    int n = swapbits(737);
    printf("n=%d\n", n);
    return 0;
}
